<template>
	<view>
		<view class="mod">
			<view style="width: 40%;">用户名</view>
			<view style="width: 60%;display: flex;">
				<input v-model="apply.userName" placeholder="请输入" style="height: 50px;text-align: right;width: 100%;"/>
			</view>
		</view>
		<view class="mod">
			<view style="width: 40%;">电话</view>
			<view style="width: 60%;display: flex;">
				<input v-model="apply.phone" placeholder="请输入" style="height: 50px;text-align: right;width: 100%;"/>
			</view>
		</view>
		<view class="mod">
			<view style="width: 40%;">年龄</view>
			<view style="width: 60%;display: flex;">
				<input v-model="apply.age" placeholder="请输入" style="height: 50px;text-align: right;width: 100%;"/>
			</view>
		</view>
		<view class="mod">
			<view style="width: 40%;">户籍地</view>
			<view style="width: 60%;display: flex;">
				<input v-model="apply.domicile" placeholder="请输入" style="height: 50px;text-align: right;width: 100%;"/>
			</view>
		</view>
		<view class="position_bottom">
			<view @click="applyPost()" class="button">立即报名</view>
		</view>
	</view>
</template>

<script>
	import api from '@/static/js/request.js'
	import data from '@/static/js/util.js'
	export default {
		data() {
			return {
				apply: {
					postId: 0,
					userId: 0,
					userName: '',
					phone: '',
					age: '',
					domicile: '',
				},
			}
		},
		onLoad(option) {
			this.apply.postId = option.postId;
		},
		methods: {
			applyPost(){
				let _this = this;
				let user = data.getUser();
				this.apply.userId = user.id;
				api.applyPost(this.apply).then((res)=>{
					console.log(res)
					uni.showToast({
						title: res.msg,
						icon: 'none',
						success() {
							setTimeout(()=>{
								uni.navigateBack()
							},1500)
						}
					})
				})
			},
		}
	}
</script>

<style>
    .mod{
		width: 90%;
		padding: 5px 5%;
		height: 50px;
		line-height: 50px;
		background-color: #FFFFFF;
		display: flex;
		margin-bottom: 1px;
		font-size: 16px;
		border-bottom: 1px solid #EDF0F2;
	}
</style>
